//
//  WatchFaceViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/19.
//

@interface WatchFaceCell : UICollectionViewCell

@end

@implementation WatchFaceCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        
    }
    return self;
}

@end




#import "WatchFaceViewController.h"

@interface WatchFaceViewController ()
@property(nonatomic,strong) NSArray *dataArray;
@end

@implementation WatchFaceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"表盘管理";
    self.view.backgroundColor = BACKGROUNDCOLOR;
    
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(15, 15, kScreenWidth - 30, kScreenHeight - NavigationContentTop - 30)];
    [self.view addSubview:scrollView];
    
    MyFlowLayout *flow = [MyFlowLayout flowLayoutWithOrientation:MyOrientation_Vert arrangedCount:3];
    flow.subviewSpace = 15;
    flow.myHorzMargin = 0;
    flow.padding = UIEdgeInsetsMake(15, 15, 15, 15);
    ViewCorner(flow, 15);
    flow.backgroundColor = COLOR_4;
    flow.myHeight = kAutoHeight;
    [scrollView addSubview:flow];
    
    
    self.dataArray = @[@"",@"",@"",@""];
    for (int i = 0; i < self.dataArray.count; i++) {
        MyLinearLayout *itemLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
        itemLay.mySize = CGSizeMake(95, 115 + 55);
        itemLay.subviewVSpace = 15;
        itemLay.gravity = MyGravity_Horz_Center;
        itemLay.myHeight = kAutoHeight;
        [flow addSubview:itemLay];
        {
            UIImageView *imageView = [[UIImageView alloc]init];
            imageView.mySize = CGSizeMake(95, 115);
            imageView.image = UIImageMake(@"watch_biaopan");
            [itemLay addSubview:imageView];
            
            UIButton *btn = UIButton.new;
            [btn setTitle:@"使用" forState:UIControlStateNormal];
            btn.titleLabel.font = UIFontMake(14);
            
            ViewCorner(btn, 15);
            ViewBorder(btn, 0.5, HexColor(@"#AAAAAA"));
            btn.mySize = CGSizeMake(64, 30);
            btn.tag = 100 + i;
            [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
            [btn setTitleColor:HexColor(@"#454545") forState:UIControlStateNormal];
            [btn setBackgroundImage:[UIImage imageWithColor:COLOR_4] forState:UIControlStateNormal];
            [btn setTitleColor:COLOR_4 forState:UIControlStateSelected];
            [btn setBackgroundImage:[UIImage imageWithColor:THEME_COLOR] forState:UIControlStateSelected];
            [itemLay addSubview:btn];
        }
    }
    
}

- (void)btnClick:(UIButton *)btn {
    
    for (int i = 0; i < self.dataArray.count; i++) {
        if(btn.tag - 100 != i){
            UIButton *otherBtn = [self.view viewWithTag:100 + i];
            otherBtn.selected = NO;
        }else{
            btn.selected = YES;
        }
    }
}


@end
